package com.oppo.action;

import java.io.PrintWriter;

import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.alibaba.fastjson.JSON;
import com.oppo.bean.CarMaxBean;
import com.oppo.service.impl.DelectCatService;
import com.oppo.tools.MyTools;
@WebServlet("/CarDelectAction")
public class CarDelectAction extends HttpServlet{
		private static final long serialVersionUID = 1L;
		protected void service(HttpServletRequest request, HttpServletResponse response) {
			try {
				
				request.setCharacterEncoding("utf-8");// 设置接收编码类型
				response.setCharacterEncoding("utf-8");// 设置发送编码数据类型
				CarMaxBean one = new CarMaxBean();
				String car_id = request.getParameter("a");// 将从客户端发送的用户名id转化为字符串		
				one.setCar_id(new Long (car_id));// 将接收的id值传给bean
				
				int list = MyTools.getNewInstance(DelectCatService.class).Delect(one);
				
				if(list!=0) {
					System.out.println("删除成功");
				}else {
					System.out.println("删除失败");
				}
				String strJson = JSON.toJSONStringWithDateFormat(list, "yyyy-MM-dd");// 借用第三方工具将list集合转换为json字符串
				PrintWriter JOIN = response.getWriter();//响应客户端的请求
				System.out.println(list);
				JOIN.write(strJson);//将字符串发送给客户端
				JOIN.flush();
				JOIN.close();

			} catch (Exception e) {
				System.out.println("用户信息接收发送错误");
				e.printStackTrace();
			}
		}

	}


